
#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int similarPairs(vector<string>& words) {
        unordered_map<int, int> hash;
        int res = 0;
        for (const auto& str : words)
        {
            int flag = 0;
            for (const auto& c : str)
            {
                flag |= (1 << (c - 'a'));
            }
            res += hash[flag]++;
        }
        return res;
    }
};